package 牛客;

import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;
import java.util.Stack;

public class 字符连连看 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String str=sc.nextLine();
        System.out.println(fun(str));
    }

    private static String fun(String str) {
        if (str.length()<2) {
            return str;
        }
        Deque<Character> stack=new ArrayDeque<>();
        stack.push(str.charAt(0));
        stack.push(str.charAt(1));

        for (int i = 2; i <str.length(); i++) {

            if (stack.size()>=2) {
                char element1=stack.pop();
                char element2=stack.peek();
                stack.push(element1);
                if (element1==str.charAt(i) && element2==str.charAt(i)) {
                    stack.pop();
                    stack.pop();
                    //把三个相同的删掉
                }else {
                    stack.push(str.charAt(i));
                }
            }else {
                stack.push(str.charAt(i));
            }
        }

        StringBuilder sb=new StringBuilder();
        int size=stack.size();
        for (int i = 0; i <size; i++) {
            sb.append(stack.pop());
        }
        return sb.reverse().toString();
    }

    private static String fun1(String str) {
        int count=1;

        for (int i = 1; i <str.length(); i++) {
            if (str.charAt(i)==str.charAt(i-1)) {
                count++;
                if (i==str.length()-1 && count>=3) {
                    //处理尾部的3个相同字符
                    str=str.substring(0,i-2);
                }
                continue;

            }else {
                if (count>=3) {
                    str=str.substring(0,i-3)+str.substring(i);
                    i=0;
                }
                count=1;
            }
        }
        return str;
    }
}
